#!/usr/bin/python

from util import Util
class Cell:
    static_id = 1
    def __init__(self, key, node=None, data = None):
        self.__key = key
        self.__node = node
        self.__data = data is not None and data or Cell.static_id
        Cell.static_id = Cell.static_id + 1


    def getKey(self):
        return self.__key
    def setKey(self, key):
        self.__key = key
    def getNode(self):
        return self.__node
    def setNode(self, node):
        self.__node = node
    def getData(self):
        return self.__data
    def setData(self, data):
        self.__data = data

    def __repr__(self):
        return "{key:%s,subNode:%x,data:%d}" % (self.__key, Util.getId(self.__node), self.__data)


import unittest
class TestCell(unittest.TestCase):
    def test(self):
        c = Cell("A")
        self.assertEqual("A", c.getKey())
        self.assertIsNone(c.getNode())
        self.assertEqual(1, c.getData())

        print "\ncell : ", c

        c = Cell("B", None, 2)
        self.assertEqual("B", c.getKey())
        self.assertIsNone(c.getNode())
        self.assertEqual(2, c.getData())

if __name__ == "__main__":
    suite = unittest.TestSuite([
        unittest.TestLoader().loadTestsFromTestCase(TestCell),
    ])
    unittest.TextTestRunner(verbosity=2).run(suite)
